package com.company.project.controller.ldjsc.zgq;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import cn.dev33.satoken.annotation.SaCheckPermission;
import com.company.project.entity.ldjsc.syjj.JscSyjjJgdxEntity;
import com.company.project.entity.ldjsc.zgq.JscwzSzgqZdtjxmEntity;
import com.company.project.service.ldjsc.zgq.JscwzSzgqZdtjxmService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.stereotype.Controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.company.project.common.utils.DataResult;





/**
 *
 *
 * @author wenbin
 * @email *****@mail.com
 * @date 2025-08-20 16:37:22
 */
@Controller
@RequestMapping("/sxzy")
public class JscwzSzgqZdtjxmController {
    @Autowired
    private JscwzSzgqZdtjxmService jscwzSzgqZdtjxmService;

    @ApiOperation(value = "重点推进项目-详情")
    @GetMapping("/jsc-dd-zt/JscZdtjxm2")
    @ResponseBody
    public DataResult JscZdtjxm2(JscwzSzgqZdtjxmEntity jscwzSzgqZdtjxm){
        LambdaQueryWrapper<JscwzSzgqZdtjxmEntity> queryWrapper = Wrappers.lambdaQuery();
        queryWrapper.eq(JscwzSzgqZdtjxmEntity::getTitle, jscwzSzgqZdtjxm.getTitle());
        queryWrapper.orderByDesc(JscwzSzgqZdtjxmEntity::getUpdate_time);

        if (jscwzSzgqZdtjxm.getMidgard_offset() != null){
            jscwzSzgqZdtjxm.setMidgard_page(1);
        }
        IPage<JscwzSzgqZdtjxmEntity> iPage = jscwzSzgqZdtjxmService.page(jscwzSzgqZdtjxm.getQueryPage(), queryWrapper);
        List<JscwzSzgqZdtjxmEntity> records = iPage.getRecords();


        // 构造所需的数据结构
        List<String> columnNames = Arrays.asList(
                "id",
                "title",
                "plan_investment",
                "land_scale",
                "estimate_value",
                "annual_plan_investment",
                "annual_done_investment",
                "accumulative_done_investment",
                "startdate",
                "plan_enddate",
                "investor",
                "description",
                "detail",
                "sort",
                "update_time",
                "index_name",
                "time_type"
        );

        Map<String, Object> result = new HashMap<>();
        result.put("columnNames", columnNames);
        result.put("value", records);

        return DataResult.success(result);
    }


    @ApiOperation(value = "重点推进项目-列表")
    @GetMapping("/jsc-dd-zt/JscZdtjxmLb2")
    @ResponseBody
    public DataResult JscZdtjxmLb2(JscwzSzgqZdtjxmEntity jscwzSzgqZdtjxm){
        LambdaQueryWrapper<JscwzSzgqZdtjxmEntity> queryWrapper = Wrappers.lambdaQuery();
        queryWrapper.orderByDesc(JscwzSzgqZdtjxmEntity::getSort);

        if (jscwzSzgqZdtjxm.getMidgard_offset() != null){
            jscwzSzgqZdtjxm.setMidgard_page(1);
        }
        IPage<JscwzSzgqZdtjxmEntity> iPage = jscwzSzgqZdtjxmService.page(jscwzSzgqZdtjxm.getQueryPage(), queryWrapper);
        List<JscwzSzgqZdtjxmEntity> records = iPage.getRecords();


        // 构造所需的数据结构
        List<String> columnNames = Arrays.asList(
                "id",
                "title",
                "plan_investment",
                "land_scale",
                "estimate_value",
                "annual_plan_investment",
                "annual_done_investment",
                "accumulative_done_investment",
                "startdate",
                "plan_enddate",
                "investor",
                "description",
                "detail",
                "sort",
                "update_time",
                "index_name",
                "time_type"
        );

        Map<String, Object> result = new HashMap<>();
        result.put("columnNames", columnNames);
        result.put("value", records);

        return DataResult.success(result);
    }



}
